﻿using SqlScriptVault.Model;
using SqlScriptVault.ViewModel;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace SqlScriptVault.View
{
    /// <summary>
    /// Interaction logic for ExecutionProgressWindow.xaml
    /// </summary>
    public partial class ExecutionProgressWindow : Window
    {
        public ExecutionProgressWindow(ScriptVaultExecution scriptVaultExecution, Dictionary<Server, SqlCredential> sqlCredentials)
        {
            InitializeComponent();
            
            ExecutionProgressViewModel viewModel = ((ExecutionProgressViewModel)DataContext);

            viewModel.ScriptVaultExecution = scriptVaultExecution;
            viewModel.SqlCredentials = sqlCredentials;
            viewModel.RequestClose += ExecutionProgressWindow_RequestClose;

            viewModel.Initialize();
        }

        void ExecutionProgressWindow_RequestClose()
        {
            DialogResult = true;

            Close();
        }
    }
}
